package com.diko.starservice.controller;


import com.diko.commonUtils.R;
import com.diko.starservice.service.DailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author Emma-Li
 * @since 2020-10-27
 */
@RestController
//@CrossOrigin
@RequestMapping("/starservice/daily")
public class DailyController {

    @Autowired
    private DailyService dailyService;

    @PostMapping("{day}")
    public R createStatisticsByDate(@PathVariable String day){
        dailyService.createStatisticsByDay(day);
        return R.ok();
    }

    @GetMapping("show-chart/{begin}/{end}/{type}")
    public R showChart(@PathVariable String begin
            ,@PathVariable String end
            ,@PathVariable String type
    ){
        Map<String,Object> map=dailyService.getChartData(begin,end,type);
        return R.ok().data(map);
    }
}

